<?php


	exit('1');

	
	ini_set('max_execution_time', '0');
	require('sql.class.php');


	$p = MyPdo::init();
	$op =  opendir('./yao');
	$i = 0;
	while($f = readdir($op)){
		if($f == '.'|| $f == '..'){
			continue;
		}
		//$i++;
		// if($i > 5){
		// 	exit;
		// }
		$path = './yao/'.$f;
		$info = file_get_contents($path);

		//提取药名
		preg_match_all('/药名：(.*)性味：/sU', $info, $res);
		$fname = preg_replace('#&[a-zA-Z]*#','',$res[1][0]);

		//提取性味
		preg_match_all('/性味：(.*)归经：/sU', $info, $res);
		$xing = preg_replace('#&[a-zA-Z]*#','',$res[1][0]);
		//提取归经
		preg_match_all('/归经：(.*)功能：/sU', $info, $res);
		$jing = preg_replace('#&[a-zA-Z]*#','',$res[1][0]);

		//提取归经
		preg_match_all('/功能：(.*)/', $info, $res);
		$gong = preg_replace('#&[a-zA-Z]*#','',$res[1][0]);

		$sql = 'insert into zhongyao values(null,?,?,?,?)';
		$res = $p->dml($sql,array($fname,$xing,$jing,$gong));
		dump($res);
	}










function dump($s,$t=false){
	echo '<pre>';
		var_dump($s);
	echo '</pre>';
	if($t){
		exit;
	}
}
